package com.saikuo.service.controller;

import com.saikuo.service.api.ApiResultModel;
import com.saikuo.service.service.IMedicineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shanchangyu on 16/10/17.
 */
@Api(value = "药品接口", description = "药品分类列别，药品详情等")
@RestController
@RequestMapping("/medicine")
public class MedicineController {

    @Autowired
    private IMedicineService medicineService;

    @ApiOperation(value = "获取药品热搜标签")
    @RequestMapping(value = "/getMedicineTopicSearchTag", method = RequestMethod.GET)
    public ApiResultModel getMedicineTopicSearchTag() {
        return medicineService.getMedicineTopicSearchTag();
    }


    @ApiOperation(value = "按照药品分类加载药品信息,支持(销量/价格)分页排序;page:页码：默认传递1，sortType:排序类型1=销量优先;2=价格优先")
    @RequestMapping(value = "/getMedicinesByCategoryId", method = RequestMethod.GET)
    public ApiResultModel getMedicinesByCategoryId(@RequestParam int categoryId, @RequestParam int sortType, @RequestParam int page) {
        return medicineService.getMedicinesByCategoryId(categoryId, sortType, page);
    }

    @ApiOperation(value = "加载热销药品信息,支持分页;page:页码:默认传递1")
    @RequestMapping(value = "/getHotSaleMedicines", method = RequestMethod.GET)
    public ApiResultModel getHotSaleMedicines(@RequestParam int page) {
        return medicineService.getHotMedicines(page);
    }

    @ApiOperation(value = "加载特卖类型药品信息")
    @RequestMapping(value = "/getTopicSaleMedicines", method = RequestMethod.GET)
    public ApiResultModel getTopicSaleMedicines(@RequestParam int topicSaleId) {
        return medicineService.getTopicSaleMedicines(topicSaleId);
    }

    @ApiOperation(value = "加载购物车药品信息,多种药品id间以英文逗号分隔")
    @RequestMapping(value = "/getMedicinesByIds", method = RequestMethod.GET)
    public ApiResultModel getMedicinesByIds(@RequestParam String medicineIds) {
        return medicineService.getMedicinesByIds(medicineIds);
    }

    @ApiOperation(value = "加载药品详情信息")
    @RequestMapping(value = "/getMedicineDetailById", method = RequestMethod.GET)
    public ApiResultModel getMedicineDetailById(@RequestParam int medicineId) {
        return medicineService.getMedicineDetailById(medicineId);
    }

}
